package com.mxchip.livestarmobile.mobile.db.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.mxchip.livestarmobile.mobile.db.entity.CallLog

@Dao
interface CallLogDao {

//    @Query("SELECT * FROM CallLog order by startTime desc")
//    fun getAll(): LiveData<List<CallLog>>

    @Query("SELECT * FROM CallLog WHERE user_id = (:userId) order by startTime desc")
    fun loadAllByUserIds(userId: String): LiveData<List<CallLog>>

    @Query("SELECT * FROM CallLog WHERE uid IN (:ids)")
    fun loadAllByIds(ids: LongArray): LiveData<List<CallLog>>

    @Query("SELECT * FROM CallLog WHERE uid = (:id)")
    fun loadAllById(id: Long): LiveData<CallLog>

    @Insert
    suspend fun insertAll(vararg callLogs: CallLog)

    @Delete
    suspend fun delete(callLog: CallLog)

    @Update
    suspend fun update(vararg callLogs: CallLog)
}